package com.ruoyi.activiti.controller;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;  
import org.springframework.boot.CommandLineRunner;  
import org.springframework.stereotype.Component;  

public class ActivitiTableInitializer implements CommandLineRunner {

    @Override
    public void run(String... args) throws Exception {
        // 使用数据源配置初始化ProcessEngine，触发建表 
        ProcessEngineConfiguration cfg = ProcessEngineConfiguration 
            .createStandaloneProcessEngineConfiguration()
            .setJdbcDriver("com.mysql.cj.jdbc.Driver")
            .setJdbcUrl("jdbc:mysql://113.44.142.255:33062/grotto_cbs?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true")
            .setJdbcUsername("root") 
            .setJdbcPassword("RSJ@123456.com")
            .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE); 
        ProcessEngine processEngine = cfg.buildProcessEngine();  
        System.out.println("Activiti 表创建成功，流程引擎名称：" + processEngine.getName());  
    } 
} 